package it.lorenz.server.core.services.login;

import it.lorenz.server.core.entities.User;
import it.lorenz.server.fk.business.ex.AbstractBusinessException;
import it.lorenz.server.fk.business.ex.ValidationException;
import it.lorenz.server.fk.services.AbstractService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("loginService")
public class LoginService extends AbstractService {

    @Transactional(readOnly = true)
    public User login(String username) {
        try {
            LoginDTO dto = (LoginDTO) executeBusinessProcess("loginBP", new LoginDTO(username));
            return dto.getUser();
        } catch (SecurityException ex) {
        } catch (ValidationException ex) {
        } catch (AbstractBusinessException ex) {
        }
        return null;
    }
}
